package ecom.beans;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Embeddable
public class PurchaseBeanPK implements Serializable {
    @Basic(optional = false)
    @Column(name = "iban", nullable = false, length = 34)
    private String iban;
    @Basic(optional = false)
    @Column(name = "id_product_store", nullable = false)
    private Long idProductStore;
    @Basic(optional = false)
    @Column(name = "id_product", nullable = false)
    private Long idProduct;
    @Basic(optional = false)
    @Column(name = "date_achat", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateAchat;

    public PurchaseBeanPK() {
    }

    public PurchaseBeanPK(String iban, Long idProductStore, Long idProduct, Date dateAchat) {
        this.iban = iban;
        this.idProductStore = idProductStore;
        this.idProduct = idProduct;
        this.dateAchat = dateAchat;
    }

    public String getIban() {
        return iban;
    }

    public void setIban(String iban) {
        this.iban = iban;
    }

    public Long getIdProductStore() {
        return idProductStore;
    }

    public void setIdProductStore(Long idProductStore) {
        this.idProductStore = idProductStore;
    }

    public long getIdProduct() {
        return idProduct;
    }

    public void setIdProduct(Long idProduct) {
        this.idProduct = idProduct;
    }

    public Date getDateAchat() {
        return dateAchat;
    }

    public void setDateAchat(Date dateAchat) {
        this.dateAchat = dateAchat;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iban != null ? iban.hashCode() : 0);
        hash +=  idProductStore;
        hash +=  idProduct;
        hash += (dateAchat != null ? dateAchat.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PurchaseBeanPK)) {
            return false;
        }
        PurchaseBeanPK other = (PurchaseBeanPK) object;
        if ((this.iban == null && other.iban != null) || (this.iban != null && !this.iban.equals(other.iban))) {
            return false;
        }
        if (this.idProductStore != other.idProductStore) {
            return false;
        }
        if (this.idProduct != other.idProduct) {
            return false;
        }
        if ((this.dateAchat == null && other.dateAchat != null) || (this.dateAchat != null && !this.dateAchat.equals(other.dateAchat))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ecom.beans.PurchaseBeanPK[iban=" + iban + ", idProductStore=" + idProductStore + ", idProduct=" + idProduct + ", dateAchat=" + dateAchat + "]";
    }

}
